layui.use(['form', 'layer'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;

    form.on("submit(editManager)", function (data) 
    {

        //获取防伪标记
        $.ajax({
            type: 'POST',
            url: '/Manager/ModifyBankCard/',
            data: {
                Id: $("#Id").val(),  //主键
                BankType: $(".BankType").val(),
                BankProvince: $(".BankProvince").val(),
                BankCity: $(".BankCity").val(),
                BankCard: $(".BankCard").val(),
            },
            dataType: "json",
            headers: {
                "X-CSRF-TOKEN-yilezhu": $("input[name='AntiforgeryKey_yilezhu']").val()
            },
            success: function (res) {//res为相应体,function为回调函数
                if (res.ResultCode === 200) {
                    var alertIndex = layer.alert(res.ResultMsg, { icon: 1 }, function () {
                        layer.closeAll("iframe");
                        //刷新父页面
                        parent.location.reload();
                        top.layer.close(alertIndex);
                    });
                    //$("#res").click();//调用重置按钮将表单数据清空
                } else if (res.ResultCode === 102) {
                    layer.alert(res.ResultMsg, { icon: 5 }, function () {
                        layer.closeAll("iframe");
                        //刷新父页面
                        parent.location.reload();
                        top.layer.close(alertIndex);
                    });
                }
                else {
                    layer.alert(res.ResultMsg, { icon: 5 });
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.alert('操作失败！！！' + XMLHttpRequest.status + "|" + XMLHttpRequest.readyState + "|" + textStatus, { icon: 5 });
            }
        });

        return false;
    });
    function GetCurrentBankCard() {
        $.ajax({
            type: 'GET',
            url: '/Manager/GetManagerBankCard/',
            data: {},
            dataType: "json",
            headers: {
                "X-CSRF-TOKEN-yilezhu": $("input[name='AntiforgeryKey_yilezhu']").val()
            },
            success: function (res) {//res为相应体,function为回调函数
                console.log(res);
                if (res.ResultCode == 200) {
                    var item = res.Data;
                    $("#Id").val(item.Id);
                    $("#BankProvince").val(item.BankProvince);
                    $(".BankCity").html("<option  value=" + item.BankCity + ">" + item.BankCity + "</option>");
                    $(".BankType").val(item.BankType);
                    $(".BankCard").val(item.BankCard);

                   form.render('select');
                } else {
                    //layer.alert(res.ResultMsg);
                }

                

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.alert('操作失败！！！' + XMLHttpRequest.status + "|" + XMLHttpRequest.readyState + "|" + textStatus, { icon: 5 });
            }
        });
    }

    GetCurrentBankCard();

});